package com.application.service.Impl;

import com.application.dao.QuestionDao;
import com.application.domain.Question;
import com.application.service.QuestionService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    QuestionDao questionDao;


    @Override
    public int save(Question question) {
        int insert = questionDao.insert(question);
        return insert;
    }

    @Override
    public int update(Question question, String id) {
        LambdaQueryWrapper<Question> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Question::getId,id);
        int update = questionDao.update(question, lqw);
        return update;
    }

    @Override
    public int delete(String id) {
        LambdaQueryWrapper<Question> lqw =new LambdaQueryWrapper<>();
        lqw.eq(Question::getId,id);
        int delete = questionDao.delete(lqw);
        return delete;
    }

    @Override
    public List<Question> selectAll() {
        List<Question> questions = questionDao.selectList(null);
        return questions;
    }

    @Override
    public Question selectById(String id) {
        Question question = questionDao.selectById(id);
        return question;
    }
}
